package org.ran.demo.http.http;

import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;

import org.ran.demo.http.util.StreamUtil;

public class SilenceTestServer {
    /**
     * 测试浏览器发送的报文
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        try (ServerSocket serverSocket = new ServerSocket();) {
            serverSocket.bind(new InetSocketAddress(8080));
            Socket socket = serverSocket.accept();
            InputStream in = socket.getInputStream();
            int counter = 0;
            while (counter < Integer.MAX_VALUE) {
                String request = StreamUtil.readLine(in);
                counter++;
                System.out.println("收到:" + request);
                System.out.println("收到行的长度为：" + request.length());
            }
            socket.close();
        } catch (Exception e) {
        }
    }
}
